package com.ciwong.epaper.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ciwong.epaper.R;


/**
 * Created by keepon on 2018/9/3.
 */
public class WordPlanItemView extends RelativeLayout {


	private final int       mIconResId;
	private final String    mName;
	private       ImageView mImageView;
	private       TextView  mTvName;


	public WordPlanItemView(Context context) {
		this(context,null);
	}

	public WordPlanItemView(Context context, AttributeSet attrs) {
		this(context, attrs,0);
	}

	public WordPlanItemView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init();
		TypedArray mTypedArray = context.obtainStyledAttributes(attrs,
				R.styleable.WordPlanItemViewView);
		mIconResId = mTypedArray.getResourceId(R.styleable.WordPlanItemViewView_icon,R.mipmap.icon_daka);
		mName = mTypedArray.getString(R.styleable.WordPlanItemViewView_name);

		mImageView.setImageResource(mIconResId);
		mTvName.setText(mName);
	}

	private void init() {
		View.inflate(getContext(), R.layout.layout_word_plan_item,this);
		mImageView = findViewById(R.id.icon);
		mTvName = findViewById(R.id.tv_name);

	}
}
